package com.xbx.admin.utils;

import com.xbx.baseweb.model.User;
import com.xbx.admin.annotation.UserInfoContext;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 用户工具类
 *
 * @author 89005691
 * @create 2018-08-31 12:21
 */
@Component
@Slf4j
public class UserUtlis {

    private static String active;

    @Value("${spring.profiles.active}")
    public void setActive(String active) {

        this.active = active;
    }

    /**
     * 获取已登录的用户信息
     *
     * @return
     */
    public static User getLoginUserInfo() {

        User user = UserInfoContext.getUser();

        if (active.equals("dev")) {

            user = new User();
            user.setId(1L);
            user.setUsername("197370");
            user.setSysUsername("hufeng");
        }

        return user == null ? null : user;
    }
}
